<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div>
        <h1>The Ajax 04 Page</h1>
        <fieldset>
            <legend>Ajax 表单请求</legend>
            <form enctype="application/x-www-form-urlencoded">
                <input type="text" name="name" id="nameId" onblur="doCheck()"/>
                <button type="button" onclick="doSave()">save</button>
            </form>
            <span id="result"></span>
        </fieldset>
    </div>
    <!--引入自定义的ajax库文件（小框架）-->
    <script src="js/ajaxfk.js"></script>
    <script>



        function doSave(){
            let url="http://localhost/doSave";
            let name=document.forms[0].name.value;
            let params=`name=${name}`;
            Ajax.doAjaxPost(url,params,function (result){
              document.getElementById("result").innerHTML=result;
            })
        }


        function doCheck(){
            let url="http://localhost/doCheck";
            let name=document.forms[0].name.value;
            let params=`name=${name}`;
            Ajax.doAjaxGet(url,params,function (result){
                document.getElementById("result").innerHTML=result;
            })
        }
    </script>
</body>
</html>